package com.wshare.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name = "account")
public class Account {
	
	@Id
	@GenericGenerator(name="increment" , strategy="increment")
	@GeneratedValue(generator="increment")
	@Column(name= "acc_id")
	private int id;
	
	@Column(name = "acc_username")
	private String username;
	
	@Column(name = "acc_password")
	private String password;
	
	@ManyToMany
	@JoinTable(name = "account_role",joinColumns={@JoinColumn(name = "acc_id")},inverseJoinColumns={@JoinColumn(name = "rol_id")})
	@Cascade({CascadeType.DELETE})
	@LazyCollection(LazyCollectionOption.FALSE)
	@JsonIgnore
	private List<Role> lRoles;

	
	public Account() {
	}

	public Account(int id, String username, String password, List<Role> lRoles) {
		this.id = id;
		this.username = username;
		this.password = password;
		this.lRoles = lRoles;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public List<Role> getlRoles() {
		return lRoles;
	}

	public void setlRoles(List<Role> lRoles) {
		this.lRoles = lRoles;
	}
	
	
	
	
}
